package fr.upstlse.glre.business.service.user;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import junit.framework.TestCase;
import fr.upstlse.glre.business.ServiceLocator;
import fr.upstlse.glre.business.service.communiquer.MessageService;
import fr.upstlse.glre.business.vo.communiquer.MessageVO;
import fr.upstlse.glre.business.vo.user.UserVO;

public class AddMessage extends TestCase {

	private static final String LOGIN = "mikl";
	
	private static final String TITRE = "message titre";
	private static final String CONTENU = "message contenu";
	private static final Date DATE = new Date();
	
	private UserService userService;
	private MessageService messageService;
	
	

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		ServiceLocator lServiceLocator = ServiceLocator.instance();
		userService = lServiceLocator.getUserService();
		messageService = lServiceLocator.getMessageService();
	}
	
	public void sendMessage() {
		UserVO lUserVO = userService.findByLogin(LOGIN);
		
		MessageVO lMessageVO = new MessageVO();
		lMessageVO.setExpediteur(lUserVO);
		lMessageVO.setTitre(TITRE);
		lMessageVO.setContenu(CONTENU);
		lMessageVO.setDate(DATE);
		List<String> lUserVOs = new ArrayList<String>();
		lUserVOs.add(lUserVO.getLogin());
		messageService.envoyer(lMessageVO,lUserVOs);
		messageService.envoyer(lMessageVO, lUserVOs);
	}
}
